package com.QK.cnstudy.adapter;

import java.util.List;
import java.util.Map;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.QK.cnstudy.R;

public class TestAdapter extends QKAdapter {

    private int resource = R.layout.test_item;

    public TestAdapter(Context context, List<Map<String, Object>> list) {
        super(context, list);
    }

    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        Map<String, Object> map = list.get(position);
        String title = (String) map.get("title");
        String desc = (String) map.get("desc");
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = inflater.inflate(resource, null);
            holder.timeTextView = (TextView) convertView.findViewById(R.id.time);
            holder.titleTextView = (TextView) convertView.findViewById(R.id.title);
            convertView.setTag(holder);
        }
        holder = (ViewHolder) convertView.getTag();

        holder.timeTextView.setText(desc);
        holder.titleTextView.setText("" + title + "");
        return convertView;
    }

    class ViewHolder {
        public TextView timeTextView;
        public TextView titleTextView;
    }
}
